package com.example.demo.controller;

import com.example.demo.service.RatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
public class RatingController {

  @Autowired
  private RatingService ratingService;

  @RequestMapping("/left")
  @CrossOrigin
  public Map left(){
    Map<String , Object> map = new HashMap<>();
    int small = ratingService.else_small();
    int medium = ratingService.else_medium();
    int large = ratingService.else_large();
    int all = ratingService.else_small();
    map.put("small", small);
    map.put("medium", medium);
    map.put("large", large);
    map.put("all", all);
    return map;
  }

  @RequestMapping("/four_eight")
  @CrossOrigin
  public Map four_eight(){
    Map<String , Object> map = new HashMap<>();
    int small = ratingService.four_eight_small();
    int medium = ratingService.four_eight_medium();
    int large = ratingService.four_eight_large();
    int all = ratingService.four_eight_small();
    map.put("small", small);
    map.put("medium", medium);
    map.put("large", large);
    map.put("all", all);
    return map;
  }

  @RequestMapping("/four_nine")
  @CrossOrigin
  public Map four_nine(){
    Map<String , Object> map = new HashMap<>();
    int small = ratingService.four_nine_small();
    int medium = ratingService.four_nine_medium();
    int large = ratingService.four_nine_large();
    int all = ratingService.four_nine_small();
    map.put("small", small);
    map.put("medium", medium);
    map.put("large", large);
    map.put("all", all);
    return map;
  }

  @RequestMapping("/five")
  @CrossOrigin
  public Map five(){
    Map<String , Object> map = new HashMap<>();
    int small = ratingService.five_small();
    int medium = ratingService.five_medium();
    int large = ratingService.five_large();
    int all = ratingService.five_small();
    map.put("small", small);
    map.put("medium", medium);
    map.put("large", large);
    map.put("all", all);
    return map;
  }

}
